package android.slc.module.user.vmbox;

import android.slc.appbase.vmbox.AffiliatedVmBox;
import android.slc.module.user.entity.User;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;

/**
 * @author slc
 * @date 2021/4/16 10:21
 */
public class UserVmBox extends AffiliatedVmBox {
    public final ObjectProperty<User> userOf = new SimpleObjectProperty<>();

    public UserVmBox() {
        this.userOf.addListener(new ChangeListener<User>() {
            @Override
            public void changed(ObservableValue<? extends User> observable, User oldValue, User newValue) {
                if (isLogin()) {

                } else {

                }
            }
        });
    }

    public User getUser() {
        return this.userOf.get();
    }

    public boolean isLogin() {
        return getUser() != null;
    }

    @Override
    public void clear() {
        this.userOf.set(null);
        super.clear();
    }
}
